<!DOCTYPE html>
<html>
<head>

<!-- meta tags -->
<meta charset="utf-8">
<meta name="keywords" content="bootstrap 4, premium, multipurpose, ecommerce, html5, css" />
<meta name="description" content="Bootstrap 4 Landing Page Template" />
<meta name="author" content="www.themesground.com" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">


<!-- Title -->
<title>佩奇牧场-不只是鲜</title>

<!-- Favicon Icon -->
<link rel="shortcut icon" href="../assets/images/pagepig.ico/">

<!-- inject css start -->

<link href="../assets/css/theme-plugin.css" rel="stylesheet" />
<link href="../assets/css/theme.min.css" rel="stylesheet" />

<!-- inject css end -->

</head>

<body>
<!-- 引入head代码 -->
<div class="head"></div>
<!-- page wrapper start -->

<div class="page-wrapper">
  <!-- preloader start -->

  <div id="ht-preloader">
    <div class="loader clear-loader"> <img class="img-fluid" src="../assets/images/loader.gif" alt=""> </div>
  </div>

  <!-- preloader end -->

  <!--hero section start-->
  <!-- 主页轮播-->
  <section class="banner pos-r p-0">
    <div class="banner-slider home-slide owl-carousel no-pb owl-2" data-dots="true" data-nav="false">
      <div class="item bg-pos-ct" data-bg-img="../assets/images/bg/bjpig2.png">
        <div class="container h-100">
          <div class="row h-100 align-items-center">
            <div class="col-lg-7 col-md-12 custom-py-2 position-relative z-index-1">
              <h6 class="font-w-6 text-black animated3">佩奇牧场</h6>
              <h1 class="mb-4 animated3 text-black">不止是"鲜"</h1>
              <div class="animated3"> <a class="btn bg-pink-btn rounded-0" href="http://127.0.0.1:8888/goods/28" name="28">精品五花 购买</a> </div>
            </div>
          </div>
        </div>
      </div>
      <div class="item bg-pos-ct" data-bg-img="../assets/images/bg/bjpig4.png">
        <div class="container h-100">
          <div class="row h-100 align-items-center">
            <div class="col-lg-7 col-md-12 custom-py-2 position-relative z-index-1">
              <h6 class="font-w-6 text-black animated3">佩奇牧场</h6>
              <h1 class="mb-4 animated3 text-black">不止是"野"</h1>
              <div class="animated3"> <a class="btn bg-aqua-btn rounded-0"href="http://127.0.0.1:8888/goods/30" name="30">特色黑猪 购买</a> </div>
            </div>
          </div>
        </div>
      </div>
      <div class="item bg-pos-ct" data-bg-img="../assets/images/bg/bjpig5.png">
        <div class="container h-100">
          <div class="row h-100 align-items-center">
            <div class="col-lg-7 col-md-12 custom-py-2 position-relative z-index-1">
              <h6 class="font-w-6 text-black animated3">佩奇牧场</h6>
              <h1 class="mb-4 animated3 text-black">不只是'小'</h1>
             <div class="animated3"> <a class="btn bg-orange-btn rounded-0" href="#">散养足够300天</a> </div>
            </div>
          </div>
        </div>
      </div>
	<div class="item bg-pos-ct" data-bg-img="../assets/images/bg/bjpig3.png">
	  <div class="container h-100">
	    <div class="row h-100 align-items-center">
	      <div class="col-lg-7 col-md-12 custom-py-2 position-relative z-index-1">
            <h1 class="mb-4 animated3 text-black" style="height: 53px;"><a href="http://127.0.0.1:8888/goods/29">￥29.99限时特价抢购</a></h1>
			<div class="countdown list-inline d-flex mt-5 mb-0 p-0" data-countdown="2021/1/10">
            </div>
	      </div>
	    </div>
	  </div>
	</div>
    </div>
  </section>

  <!--hero section end-->

  <section class="banner-row full pt-4 pb-0">
    <div class="container-fluid">
      <div class="row">
        <div class="col-12 col-lg-4 col-md-6">
          <div class="position-relative rounded overflow-hidden">
		  <!-- 轮播下面的3个图-->
            <!-- Background -->
            <img class="img-fluid hover-zoom" src="../assets/images/product-ad/index0001.jpg" alt="">
            <!-- Body -->
            <div class="position-absolute top-50 pl-5">
              <h6 class="text-dark">猪排骨</h6>
              <!-- Heading -->
              <h3 class="text-dark font-w-7">炖着更好吃 <br>
                香飘十里</h3>
              <!-- Link --> <a class="more-link text-dark" href="http://127.0.0.1:8888/goods/29">购买</a> </div>
          </div>
        </div>
        <div class="col-12 col-lg-4 col-md-6 mt-5 mt-md-0">
          <div class="position-relative rounded overflow-hidden">
            <!-- Background -->
            <img class="img-fluid hover-zoom" src="../assets/images/product-ad/index0002.jpg" alt="">
            <!-- Body -->
            <div class="position-absolute top-50 pl-5">
              <h6 class="text-dark">本地农家猪</h6>
              <!-- Heading -->
              <h3 class="font-w-7 text-dark">无饲料添加 <br>
                又香又嫩</h3>
              <!-- Link --> <a class="more-link text-dark" href="http://127.0.0.1:8888/goods/26">购买</a> </div>
          </div>
        </div>
        <div class="col-12 col-lg-4 col-md-12 mt-5 mt-lg-0 d-md-none d-lg-block">
          <div class="position-relative rounded overflow-hidden">
            <!-- Background -->
            <img class="img-fluid hover-zoom" src="../assets/images/product-ad/index0003.jpg" alt="">
            <!-- Body -->
            <div class="position-absolute top-50 pl-5">
              <h6 class="text-dark">腊肉</h6>
              <!-- Heading -->
              <h3 class="font-w-7">烟熏腊肉<br>
                有"年味"</h3>
              <!-- Link --> <a class="more-link text-dark" href="http://127.0.0.1:8888/goods/19">购买</a> </div>
          </div>
        </div>
      </div>
    </div>
  </section>

  <!--body content start-->

  <div class="page-content">

    <!--product start-->

    <section class="pb-6">
      <div class="container">
        <div class="row justify-content-center text-center mb-4">
          <div class="col-lg-6 col-md-10">
            <div>
              <h2 class="mb-0 font-w-6">佩奇牧场 新鲜速达</h2>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col">
            <div class="tab">
              <nav class="mb-5 text-center">
                <div class="nav nav-tabs nav-tabs-div d-inline-block justify-content-md-end" id="nav-tab" role="tablist">
                  <a href="javascript:void(0)" id="nav-tab1" onclick="reShowRandomGoods()">以下商品都不满意？点击刷新试试吧(ง •_•)ง</a>
                </div>
              </nav>
              <div class="tab-content p-0" id="nav-tabContent">
                <div role="tabpanel" id="tab1-1">
                  <!--商品展示位置-->
                  <div class="row" id="goodsRow">

                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!--product end-->

    <!--feature start-->

    <section class="bg-pink-light pt-8 pb-8">
      <div class="container">
        <!-- / .row -->
        <div class="row text-center">
          <div class="col-lg-4 col-sm-6">
            <div class="mx-10"> <i class="las la-truck ic-2x text-dark"></i>
              <h5 class="mb-1">45分钟内快速送达<br>保证"鲜美"送达</h5>
            </div>
          </div>
          <div class="col-lg-4 col-sm-6 mt-3 mt-sm-0">
            <div class="mx-10"> <i class="las la-wallet ic-2x text-dark"></i>
              <h5 class="mb-1">多元支付方式<br>安全 方便 快捷</h5>
            </div>
          </div>
          <div class="col-lg-4 col-sm-12 mt-3 mt-lg-0">
            <div class="mx-10"> <i class="las la-mobile ic-2x text-dark"></i>
              <h5 class="mb-1">联系我们<br>+400 99886666</h5>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!--feature end-->

    <!--product start-->

    <section class="pb-5">
      <div class="container">
        <div class="row">
          <div class="col">
            <div class="tab">
              <nav class="mb-5 text-center">
                <div class="nav nav-tabs nav-tabs-div d-inline-block justify-content-md-end"  role="tablist">
                  <h2 class="mb-0 font-w-6">特色菜谱</h2>
                </div>
              </nav>
              <div class="tab-content p-0" >
                <div role="tabpanel" class="tab-pane fade show active" >
                  <!--商品展示位置-->
                  <div class="row list"  >

                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>



  <!--body content end-->

  <!--底部 end-->

</div>

<!-- page wrapper end -->


<!--back-to-top start-->

<div class="scroll-top"><a class="smoothscroll" href="#top"><i class="las la-angle-up"></i></a></div>

<!--back-to-top end-->

<!-- 引入footer代码 -->
<div class="footer"></div>
<!-- inject js start -->

<script src="../assets/js/jquery-3.5.1.min.js"></script>
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<!--<script src="../assets/js/owl.carousel.min.js"></script>-->
<script src="../assets/js/light-slider.js"></script>
<script src="../assets/js/parallax.js"></script>
<script src="../assets/js/magnific-popup.min.js"></script>
<script src="../assets/js/jquery.countdown.min.js"></script>
<script src="../assets/js/jquery.dd.min.js"></script>
<script src="../assets/js/validator.js"></script>
<script src="../assets/js/wow.js"></script>
<script src="../assets/js/theme-script.js"></script>
<script type="text/javascript">
    $(function(){
      //进行随机商品的回显
      reShowRandomGoods();
    });

    function run(){
      var date = new Date();
      var year = date.getFullYear();		//getYear()缺陷已经废除
      var month = date.getMonth()+1;	//从0开始
      var day = date.getDate();
      document.getElementByName('data-countdown').innerHTML
              = year+'/'+month+'/'+day;
    }

    function reShowRandomGoods() {
      $.ajax({
        url:"/goods/doGetRandomGoods",
        success:(result) =>{
          creatDiv(result.data);
        }
      })
    }

    function creatDiv(records) {
      $("#goodsRow").empty();
      for (let i = 0; i < records.length; i++) {
        let data = records[i];
        let imgArr = data.img.split(",");
        let str = "<div class='col-lg-3 col-md-6 mb-5'>"+
                "<div class='card product-card card--default rounded-0'>"+
                "<a class='card-img-hover d-block' id='hiddenId' value='"+data.id+"' href='/goods/"+data.id+"'>"+
                "<img class='card-img-back' id='itemImg' value='"+imgArr[0]+"' src='"+imgArr[0]+"' alt='...'>"+
                "<img class='card-img-front' src='"+imgArr[1]+"' alt='...'>" +
                "</a>"+
                "<div class='card-info'>" +
                "<div class='card-body'>"+
                "<div class='product-title font-w-5'>" +
                "<a class='link-title' id='title' value='"+data.title+"'>"+data.title+"</a>" +
                "</div>" +
                "<div class='mt-1'>"+
                "<span class='product-price text-pink' id='itemPrice' value='"+data.price+"'>"+data.price+"</span>" +
                "<div class='star-rating'>" +
                "<i class='las la-star'></i><i class='las la-star'></i><i class='las la-star'></i><i class='las la-star'></i><i class='las la-star'></i></div></div></div>"+
                "<div class='card-footer bg-transparent border-0'>"+
                "<div class='product-link d-flex align-items-center justify-content-center'>"+
                "<button class='btn-cart btn btn-pink mx-3' type='button' onclick='addCart()'>"+
                "<i class='las la-shopping-cart mr-1'></i> 添加购物车</button></div></div></div>";
        $("#goodsRow").append(str);
      }
    }

</script>

<script>
  /*添加到购物车*/
  function addCart(){
    let itemId =document.getElementById("hiddenId").getAttribute("value");
    let itemNum =1;
    let title=document.getElementById("title").getAttribute("value");
    let itemPrice0=document.getElementById("itemPrice").getAttribute("value");
    let itemPrice=(itemPrice0*100).toFixed(0);
    let itemImg =document.getElementById("itemImg").getAttribute("value");
    $.ajax({
      url:"/page/addCartByUserName",
      type:"get",
      data:{itemId:itemId,num:itemNum,itemPrice:itemPrice,itemTitle:title,itemImage:itemImg},
      contentType:"application/x-www-form-urlencoded; charset=utf-8",
      dataType:"json",
      success:function (data){
        if (data.status==200){ alert("添加购物车成功");}
        else{window.location.href = '/page/login.html';}

      }
    })
  }

</script>


<script type="text/javascript">
    //在js中引入head和footer
    $(document).ready(function () {
      $('.head').load('head.html');
      doGetObjects();
      $('.footer').load('footer.html');
    });

    function doGetObjects() {

     var pageCurrent = 1;
      var params = {
        "pageCurrent": pageCurrent
      };
     params.username = "";

      let url = "/recipes/doFindRecipes";
      $.getJSON(url, params, function(result) {
        console.log(result);
        if (result.status == 200) {
          doCreatedLi(result.data.records);
        } else {
          alert(result.message)
          // doGetObjects();
        }


      });
    }
    function doCreatedLi(data) {
      for (i = 0; i < data.length; i++) {
        let url = "/page/doDetail?id=" + data[i].id;
        let div = `<div class='col-lg-3 col-md-6 mb-5'>
                    <div class="card product-card card--default rounded-0">
                        <a class="card-img-hover d-block" href="${url}">
                            <img class="card-img-back" src="${data[i].finishedImg}"  height='174' title="${data[i].menuName}">
                            <img class='card-img-front' src="${data[i].finishedImg}" title='${data[i].menuName}'>
                        </a>
                      <div class="card-info">
                        <div class="card-body">
                          <div class="product-title font-w-5">&emsp;&emsp;${data[i].described} </div>
                        </div>
                        <div class="card-footer bg-transparent border-0">
                          <div class="product-link d-flex align-items-center justify-content-center">
                            <button class="btn-cart btn btn-pink mx-3" type="button"> ${data[i].menuName} </button>
                          </div>
                        </div>
                      </div>
                    </div>
                   </div>`;
        $(".list").append(div);
      }
    }
</script>
<!-- inject js end -->
</body>
</html>
